import request from '@/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/blade-iot/group/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getPage = (current, size, deviceId) => {
  return request({
    url: '/blade-iot/group/page',
    method: 'get',
    params: {
      deviceId,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/blade-iot/group/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const getTree = (tenantId) => {
  return request({
    url: '/blade-iot/group/tree',
    method: 'get',
    params: {
      tenantId,
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/blade-iot/group/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/blade-iot/group/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/blade-iot/group/submit',
    method: 'post',
    data: row
  })
}

export const addGroupDevice = (deviceId, groupId) => {
  return request({
    url: '/blade-iot/group/device/submit',
    method: 'post',
    params: {
      deviceId,
      groupId
    }
  })
}

export const unbindGroupDevice = (deviceId, groupId) => {
  return request({
    url: '/blade-iot/group/device/unbind',
    method: 'post',
    params: {
      deviceId,
      groupId
    }
  })
}

export const getGroupDeviceCount = (groupId) => {
  return request({
    url: '/blade-iot/group/device/device-count',
    method: 'get',
    params: {
      groupId
    }
  })
}


